import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Game {
    private static final String[] suits={"♥","♣","♦","♠"};
    public List<Poker> buyPoker(){//买回52张牌
        List<Poker> pokers=new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j < 14; j++) {

                Poker poker=new Poker(suits[i], j);//一张扑克
                pokers.add(poker);//扑克加入扑克集
            }

        }
        return pokers;
    }
    public void shuffle(List<Poker> pokers){//洗牌操作

        for (int i = pokers.size()-1; i >0; i--) {//下标从i-1开始
            Random random=new Random();
            int index= random.nextInt(i);//从0到i，不包括i
            swap(pokers,i,index);//从0~i-1位取出一个pokers[index]给pokers[i]
        }
    }
    public void swap(List<Poker> pokers,int i,int j){
        Poker tmp=pokers.get(i);
        pokers.set(i,pokers.get(j));//pokers[j]的值给第i位的pokers
        pokers.set(j,tmp);
    }
    public List<List<Poker>> game(List<Poker> pokers){
        List<List<Poker>> hand=new ArrayList<>();

        List<Poker> hand1=new ArrayList<>();
        List<Poker> hand2=new ArrayList<>();
        List<Poker> hand3=new ArrayList<>();

        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Poker removepoker=pokers.remove(0);//被删除的牌视为被拿走
                hand.get(j).add(removepoker);
            }
        }
        return hand;
    }
}
